using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Xml;
using System.Xml.Serialization;

namespace UIProcessSchemaObjects
{
    public static class FormHelper
    {
        public static UIProcessSchemaObjects.Form LoadForm(string strFileName)
        {
            // Declare an object variable of the type to be deserialized.
            Form theForm = new Form();

            try
            {
                if (File.Exists(strFileName))
                {
                    // Create an instance of the XmlSerializer class;
                    // specify the type of object to be deserialized.
                    XmlSerializer serializer = new XmlSerializer(theForm.GetType(), "http://formsanywhere.net/uiprocess/2009/03");
                    // To read the file, create a FileStream.
                    FileStream myFileStream = new FileStream(strFileName, FileMode.Open);
                    // Call the Deserialize method and cast to the object type.
                    theForm = (Form)serializer.Deserialize(myFileStream);
                    // close the file
                    myFileStream.Close();
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.ToString());
            }

            return theForm;
        }

        public static bool SaveForm(Form theForm, string strFileName)
        {
            bool bResult = false;

            try
            {
                // Create an instance of the XmlSerializer class;
                // specify the type of object to serialize.
                XmlSerializer serializer = new XmlSerializer(theForm.GetType(), "http://formsanywhere.net/uiprocess/2009/03");
                TextWriter writer = new StreamWriter(strFileName);
                // Serialize the Form, and close the TextWriter.
                serializer.Serialize(writer, theForm);
                writer.Close();

                bResult = true;
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.ToString());

                bResult = false;
            }

            return bResult;
        }

        public static FormsList LoadFormList(string strPath)
        {
            int nIndex = 0;
            string[] formTemplates = Directory.GetFiles(strPath);

            FormsList formList = new FormsList();
            formList.Form = new string[formTemplates.Length];

            foreach (string strTemp in formTemplates)
            {
                int nPos = strTemp.LastIndexOf('\\');
                string strTemp1 = strTemp.Substring(nPos + 1, strTemp.Length - (nPos + 1));
                formList.Form[nIndex++] = strTemp1;
            }

            return formList;
        }

        public static bool DeleteFormTemplate(string strPath)
        {
            bool bResult = false;

            try
            {
                if (File.Exists(strPath))
                {
                    File.Delete(strPath);
                    bResult = true;
                }
                else
                {
                    bResult = false;
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);

                bResult = false;
            }

            return bResult;
        }

        public static string FindFormResourceValue(UIProcessSchemaObjects.Form theForm, string theFormResourceName, string theFieldName)
        {
            UIProcessSchemaObjects.FormResource _theResource = null;
            string strResult = "";

            foreach (UIProcessSchemaObjects.FormResource objTemp in theForm.FormResources)
            {
                if (objTemp.Name == theFormResourceName)
                {
                    _theResource = objTemp;
                    break;
                }
            }

            if (_theResource is UIProcessSchemaObjects.AddressEntryNA)
            {
                UIProcessSchemaObjects.AddressEntryNA _theEntry = (UIProcessSchemaObjects.AddressEntryNA)_theResource;
                switch (theFieldName)
                {
                    default:
                    case "Name":
                        strResult = _theEntry.Name;
                        break;
                    case "Title":
                        strResult = _theEntry.Title;
                        break;
                    case "Prompt":
                        strResult = _theEntry.Prompt;
                        break;
                    case "Completed":
                        strResult = _theEntry.Completed.ToString();
                        break;
                    case "Required":
                        strResult = _theEntry.Required.ToString();
                        break;
                    case "Address1":
                        strResult = _theEntry.Address1;
                        break;
                    case "Address2":
                        strResult = _theEntry.Address2;
                        break;
                    case "City":
                        strResult = _theEntry.City;
                        break;
                    case "State":
                        strResult = _theEntry.State;
                        break;
                    case "PostalCode":
                        strResult = _theEntry.PostalCode;
                        break;
                    case "CountryCode":
                        strResult = _theEntry.CountryCode;
                        break;
                    case "NotApplicable":
                        strResult = _theEntry.NotApplicable.ToString();
                        break;
                }
            }
            else if (_theResource is UIProcessSchemaObjects.AddressEntry)
            {
                UIProcessSchemaObjects.AddressEntry _theEntry = (UIProcessSchemaObjects.AddressEntry)_theResource;
                switch (theFieldName)
                {
                    default:
                    case "Name":
                        strResult = _theEntry.Name;
                        break;
                    case "Title":
                        strResult = _theEntry.Title;
                        break;
                    case "Prompt":
                        strResult = _theEntry.Prompt;
                        break;
                    case "Completed":
                        strResult = _theEntry.Completed.ToString();
                        break;
                    case "Required":
                        strResult = _theEntry.Required.ToString();
                        break;
                    case "Address1":
                        strResult = _theEntry.Address1;
                        break;
                    case "Address2":
                        strResult = _theEntry.Address2;
                        break;
                    case "City":
                        strResult = _theEntry.City;
                        break;
                    case "State":
                        strResult = _theEntry.State;
                        break;
                    case "PostalCode":
                        strResult = _theEntry.PostalCode;
                        break;
                    case "CountryCode":
                        strResult = _theEntry.CountryCode;
                        break;
                }
            }
            else if (_theResource is UIProcessSchemaObjects.Conditional)
            {
                UIProcessSchemaObjects.Conditional _theEntry = (UIProcessSchemaObjects.Conditional)_theResource;
                switch (theFieldName)
                {
                    default:
                    case "Name":
                        strResult = _theEntry.Name;
                        break;
                    case "Title":
                        strResult = _theEntry.Title;
                        break;
                    case "Prompt":
                        strResult = _theEntry.Prompt;
                        break;
                    case "Completed":
                        strResult = _theEntry.Completed.ToString();
                        break;
                    case "Required":
                        strResult = _theEntry.Required.ToString();
                        break;
                    case "Expression":
                        strResult = _theEntry.Expression;
                        break;
                    case "JumpToFormResource":
                        strResult = _theEntry.JumpToFormResource;
                        break;
                }
            }
            else if (_theResource is UIProcessSchemaObjects.DataField)
            {
                UIProcessSchemaObjects.DataField _theEntry = (UIProcessSchemaObjects.DataField)_theResource;
                switch (theFieldName)
                {
                    default:
                    case "Name":
                        strResult = _theEntry.Name;
                        break;
                    case "Title":
                        strResult = _theEntry.Title;
                        break;
                    case "Prompt":
                        strResult = _theEntry.Prompt;
                        break;
                    case "Completed":
                        strResult = _theEntry.Completed.ToString();
                        break;
                    case "Required":
                        strResult = _theEntry.Required.ToString();
                        break;
                    case "FieldValue":
                        strResult = _theEntry.FieldValue;
                        break;
                }
            }
            else if (_theResource is UIProcessSchemaObjects.DateTimeEntryNA)
            {
                UIProcessSchemaObjects.DateTimeEntryNA _theEntry = (UIProcessSchemaObjects.DateTimeEntryNA)_theResource;
                switch (theFieldName)
                {
                    default:
                    case "Name":
                        strResult = _theEntry.Name;
                        break;
                    case "Title":
                        strResult = _theEntry.Title;
                        break;
                    case "Prompt":
                        strResult = _theEntry.Prompt;
                        break;
                    case "Completed":
                        strResult = _theEntry.Completed.ToString();
                        break;
                    case "Required":
                        strResult = _theEntry.Required.ToString();
                        break;
                    case "Date":
                        strResult = _theEntry.Date;
                        break;
                    case "Time":
                        strResult = _theEntry.Time;
                        break;
                    case "NotApplicable":
                        strResult = _theEntry.NotApplicable.ToString();
                        break;
                }
            }
            else if (_theResource is UIProcessSchemaObjects.DateTimeEntry)
            {
                UIProcessSchemaObjects.DateTimeEntry _theEntry = (UIProcessSchemaObjects.DateTimeEntry)_theResource;
                switch (theFieldName)
                {
                    default:
                    case "Name":
                        strResult = _theEntry.Name;
                        break;
                    case "Title":
                        strResult = _theEntry.Title;
                        break;
                    case "Prompt":
                        strResult = _theEntry.Prompt;
                        break;
                    case "Completed":
                        strResult = _theEntry.Completed.ToString();
                        break;
                    case "Required":
                        strResult = _theEntry.Required.ToString();
                        break;
                    case "Date":
                        strResult = _theEntry.Date;
                        break;
                    case "Time":
                        strResult = _theEntry.Time;
                        break;
                }
            }
            else if (_theResource is UIProcessSchemaObjects.DateEntryNA)
            {
                UIProcessSchemaObjects.DateEntryNA _theEntry = (UIProcessSchemaObjects.DateEntryNA)_theResource;
                switch (theFieldName)
                {
                    default:
                    case "Name":
                        strResult = _theEntry.Name;
                        break;
                    case "Title":
                        strResult = _theEntry.Title;
                        break;
                    case "Prompt":
                        strResult = _theEntry.Prompt;
                        break;
                    case "Completed":
                        strResult = _theEntry.Completed.ToString();
                        break;
                    case "Required":
                        strResult = _theEntry.Required.ToString();
                        break;
                    case "Date":
                        strResult = _theEntry.Date;
                        break;
                    case "NotApplicable":
                        strResult = _theEntry.NotApplicable.ToString();
                        break;
                }
            }
            else if (_theResource is UIProcessSchemaObjects.DateEntry)
            {
                UIProcessSchemaObjects.DateEntry _theEntry = (UIProcessSchemaObjects.DateEntry)_theResource;
                switch (theFieldName)
                {
                    default:
                    case "Name":
                        strResult = _theEntry.Name;
                        break;
                    case "Title":
                        strResult = _theEntry.Title;
                        break;
                    case "Prompt":
                        strResult = _theEntry.Prompt;
                        break;
                    case "Completed":
                        strResult = _theEntry.Completed.ToString();
                        break;
                    case "Required":
                        strResult = _theEntry.Required.ToString();
                        break;
                    case "Date":
                        strResult = _theEntry.Date;
                        break;
                }
            }
            else if (_theResource is UIProcessSchemaObjects.GraphicAnnotation)
            {
                UIProcessSchemaObjects.GraphicAnnotation _theEntry = (UIProcessSchemaObjects.GraphicAnnotation)_theResource;
                switch (theFieldName)
                {
                    default:
                    case "Name":
                        strResult = _theEntry.Name;
                        break;
                    case "Title":
                        strResult = _theEntry.Title;
                        break;
                    case "Prompt":
                        strResult = _theEntry.Prompt;
                        break;
                    case "Completed":
                        strResult = _theEntry.Completed.ToString();
                        break;
                    case "Required":
                        strResult = _theEntry.Required.ToString();
                        break;
                    case "FullScreen":
                        strResult = _theEntry.FullScreen.ToString();
                        break;
                    case "DisplayMode":
                        strResult = _theEntry.DisplayMode.ToString();
                        break;
                    case "ImageBytes":
                        strResult = _theEntry.ImageBytes;
                        break;
                    case "AnnotationBytes":
                        strResult = _theEntry.AnnotationBytes;
                        break;
                }
            }
            else if (_theResource is UIProcessSchemaObjects.GraphicDisplay)
            {
                UIProcessSchemaObjects.GraphicDisplay _theEntry = (UIProcessSchemaObjects.GraphicDisplay)_theResource;
                switch (theFieldName)
                {
                    default:
                    case "Name":
                        strResult = _theEntry.Name;
                        break;
                    case "Title":
                        strResult = _theEntry.Title;
                        break;
                    case "Prompt":
                        strResult = _theEntry.Prompt;
                        break;
                    case "Completed":
                        strResult = _theEntry.Completed.ToString();
                        break;
                    case "Required":
                        strResult = _theEntry.Required.ToString();
                        break;
                    case "FullScreen":
                        strResult = _theEntry.FullScreen.ToString();
                        break;
                    case "DisplayMode":
                        strResult = _theEntry.DisplayMode.ToString();
                        break;
                    case "ImageBytes":
                        strResult = _theEntry.ImageBytes;
                        break;
                }
            }
            else if (_theResource is UIProcessSchemaObjects.MultiSelectOtherEntry)
            {
                UIProcessSchemaObjects.MultiSelectOtherEntry _theEntry = (UIProcessSchemaObjects.MultiSelectOtherEntry)_theResource;
                switch (theFieldName)
                {
                    default:
                    case "Name":
                        strResult = _theEntry.Name;
                        break;
                    case "Title":
                        strResult = _theEntry.Title;
                        break;
                    case "Prompt":
                        strResult = _theEntry.Prompt;
                        break;
                    case "Completed":
                        strResult = _theEntry.Completed.ToString();
                        break;
                    case "Required":
                        strResult = _theEntry.Required.ToString();
                        break;
                    case "Options":
                        foreach (string strTemp in _theEntry.Options)
                        {
                            strResult += strTemp;
                            strResult += ":";
                        }
                        break;
                    case "Selections":
                        foreach (string strTemp in _theEntry.Selections)
                        {
                            strResult += strTemp;
                            strResult += ":";
                        }
                        break;
                    case "OtherSelected":
                        strResult = _theEntry.OtherSelected.ToString();
                        break;
                    case "OtherValue":
                        strResult = _theEntry.OtherValue;
                        break;
                }
            }
            else if (_theResource is UIProcessSchemaObjects.MultiSelectEntry)
            {
                UIProcessSchemaObjects.MultiSelectEntry _theEntry = (UIProcessSchemaObjects.MultiSelectEntry)_theResource;
                switch (theFieldName)
                {
                    default:
                    case "Name":
                        strResult = _theEntry.Name;
                        break;
                    case "Title":
                        strResult = _theEntry.Title;
                        break;
                    case "Prompt":
                        strResult = _theEntry.Prompt;
                        break;
                    case "Completed":
                        strResult = _theEntry.Completed.ToString();
                        break;
                    case "Required":
                        strResult = _theEntry.Required.ToString();
                        break;
                    case "Options":
                        foreach (string strTemp in _theEntry.Options)
                        {
                            strResult += strTemp;
                            strResult += ":";
                        }
                        break;
                    case "Selections":
                        foreach (string strTemp in _theEntry.Selections)
                        {
                            strResult += strTemp;
                            strResult += ":";
                        }
                        break;
                }
            }
            else if (_theResource is UIProcessSchemaObjects.NameEntry)
            {
                UIProcessSchemaObjects.NameEntry _theEntry = (UIProcessSchemaObjects.NameEntry)_theResource;
                switch (theFieldName)
                {
                    default:
                    case "Name":
                        strResult = _theEntry.Name;
                        break;
                    case "Title":
                        strResult = _theEntry.Title;
                        break;
                    case "Prompt":
                        strResult = _theEntry.Prompt;
                        break;
                    case "Completed":
                        strResult = _theEntry.Completed.ToString();
                        break;
                    case "Required":
                        strResult = _theEntry.Required.ToString();
                        break;
                    case "NameTitle":
                        strResult = _theEntry.NameTitle;
                        break;
                    case "Given":
                        strResult = _theEntry.Given;
                        break;
                    case "Middle":
                        strResult = _theEntry.Middle;
                        break;
                    case "Family":
                        strResult = _theEntry.Family;
                        break;
                    case "Suffix":
                        strResult = _theEntry.Suffix;
                        break;
                }
            }
            else if (_theResource is UIProcessSchemaObjects.NoteEntry)
            {
                UIProcessSchemaObjects.NoteEntry _theEntry = (UIProcessSchemaObjects.NoteEntry)_theResource;
                switch (theFieldName)
                {
                    default:
                    case "Name":
                        strResult = _theEntry.Name;
                        break;
                    case "Title":
                        strResult = _theEntry.Title;
                        break;
                    case "Prompt":
                        strResult = _theEntry.Prompt;
                        break;
                    case "Completed":
                        strResult = _theEntry.Completed.ToString();
                        break;
                    case "Required":
                        strResult = _theEntry.Required.ToString();
                        break;
                    case "NoteText":
                        strResult = _theEntry.NoteText;
                        break;
                }
            }
            else if (_theResource is UIProcessSchemaObjects.NumberEntryNA)
            {
                UIProcessSchemaObjects.NumberEntryNA _theEntry = (UIProcessSchemaObjects.NumberEntryNA)_theResource;
                switch (theFieldName)
                {
                    default:
                    case "Name":
                        strResult = _theEntry.Name;
                        break;
                    case "Title":
                        strResult = _theEntry.Title;
                        break;
                    case "Prompt":
                        strResult = _theEntry.Prompt;
                        break;
                    case "Completed":
                        strResult = _theEntry.Completed.ToString();
                        break;
                    case "Required":
                        strResult = _theEntry.Required.ToString();
                        break;
                    case "NumberValue":
                        strResult = _theEntry.NumberValue;
                        break;
                    case "NotApplicable":
                        strResult = _theEntry.NotApplicable.ToString();
                        break;
                }
            }
            else if (_theResource is UIProcessSchemaObjects.NumberEntry)
            {
                UIProcessSchemaObjects.NumberEntry _theEntry = (UIProcessSchemaObjects.NumberEntry)_theResource;
                switch (theFieldName)
                {
                    default:
                    case "Name":
                        strResult = _theEntry.Name;
                        break;
                    case "Title":
                        strResult = _theEntry.Title;
                        break;
                    case "Prompt":
                        strResult = _theEntry.Prompt;
                        break;
                    case "Completed":
                        strResult = _theEntry.Completed.ToString();
                        break;
                    case "Required":
                        strResult = _theEntry.Required.ToString();
                        break;
                    case "NumberValue":
                        strResult = _theEntry.NumberValue;
                        break;
                }
            }
            else if (_theResource is UIProcessSchemaObjects.PasswordEntry)
            {
                UIProcessSchemaObjects.PasswordEntry _theEntry = (UIProcessSchemaObjects.PasswordEntry)_theResource;
                switch (theFieldName)
                {
                    default:
                    case "Name":
                        strResult = _theEntry.Name;
                        break;
                    case "Title":
                        strResult = _theEntry.Title;
                        break;
                    case "Prompt":
                        strResult = _theEntry.Prompt;
                        break;
                    case "Completed":
                        strResult = _theEntry.Completed.ToString();
                        break;
                    case "Required":
                        strResult = _theEntry.Required.ToString();
                        break;
                    case "Password":
                        strResult = _theEntry.Password;
                        break;
                }
            }
            else if (_theResource is UIProcessSchemaObjects.PhoneEntryNA)
            {
                UIProcessSchemaObjects.PhoneEntryNA _theEntry = (UIProcessSchemaObjects.PhoneEntryNA)_theResource;
                switch (theFieldName)
                {
                    default:
                    case "Name":
                        strResult = _theEntry.Name;
                        break;
                    case "Title":
                        strResult = _theEntry.Title;
                        break;
                    case "Prompt":
                        strResult = _theEntry.Prompt;
                        break;
                    case "Completed":
                        strResult = _theEntry.Completed.ToString();
                        break;
                    case "Required":
                        strResult = _theEntry.Required.ToString();
                        break;
                    case "NationalCode":
                        strResult = _theEntry.NationalCode;
                        break;
                    case "CountryCode":
                        strResult = _theEntry.CountryCode;
                        break;
                    case "AreaCode":
                        strResult = _theEntry.AreaCode;
                        break;
                    case "Number":
                        strResult = _theEntry.Number;
                        break;
                    case "Extension":
                        strResult = _theEntry.Extension;
                        break;
                    case "Pin":
                        strResult = _theEntry.Pin;
                        break;
                    case "NotApplicable":
                        strResult = _theEntry.NotApplicable.ToString();
                        break;
                }
            }
            else if (_theResource is UIProcessSchemaObjects.PhoneEntry)
            {
                UIProcessSchemaObjects.PhoneEntry _theEntry = (UIProcessSchemaObjects.PhoneEntry)_theResource;
                switch (theFieldName)
                {
                    default:
                    case "Name":
                        strResult = _theEntry.Name;
                        break;
                    case "Title":
                        strResult = _theEntry.Title;
                        break;
                    case "Prompt":
                        strResult = _theEntry.Prompt;
                        break;
                    case "Completed":
                        strResult = _theEntry.Completed.ToString();
                        break;
                    case "Required":
                        strResult = _theEntry.Required.ToString();
                        break;
                    case "NationalCode":
                        strResult = _theEntry.NationalCode;
                        break;
                    case "CountryCode":
                        strResult = _theEntry.CountryCode;
                        break;
                    case "AreaCode":
                        strResult = _theEntry.AreaCode;
                        break;
                    case "Number":
                        strResult = _theEntry.Number;
                        break;
                    case "Extension":
                        strResult = _theEntry.Extension;
                        break;
                    case "Pin":
                        strResult = _theEntry.Pin;
                        break;
                }
            }
            else if (_theResource is UIProcessSchemaObjects.PostalCodeEntryNA)
            {
                UIProcessSchemaObjects.PostalCodeEntryNA _theEntry = (UIProcessSchemaObjects.PostalCodeEntryNA)_theResource;
                switch (theFieldName)
                {
                    default:
                    case "Name":
                        strResult = _theEntry.Name;
                        break;
                    case "Title":
                        strResult = _theEntry.Title;
                        break;
                    case "Prompt":
                        strResult = _theEntry.Prompt;
                        break;
                    case "Completed":
                        strResult = _theEntry.Completed.ToString();
                        break;
                    case "Required":
                        strResult = _theEntry.Required.ToString();
                        break;
                    case "PostalCode":
                        strResult = _theEntry.PostalCode;
                        break;
                    case "NotApplicable":
                        strResult = _theEntry.NotApplicable.ToString();
                        break;
                }
            }
            else if (_theResource is UIProcessSchemaObjects.PostalCodeEntry)
            {
                UIProcessSchemaObjects.PostalCodeEntry _theEntry = (UIProcessSchemaObjects.PostalCodeEntry)_theResource;
                switch (theFieldName)
                {
                    default:
                    case "Name":
                        strResult = _theEntry.Name;
                        break;
                    case "Title":
                        strResult = _theEntry.Title;
                        break;
                    case "Prompt":
                        strResult = _theEntry.Prompt;
                        break;
                    case "Completed":
                        strResult = _theEntry.Completed.ToString();
                        break;
                    case "Required":
                        strResult = _theEntry.Required.ToString();
                        break;
                    case "PostalCode":
                        strResult = _theEntry.PostalCode;
                        break;
                }
            }
            else if (_theResource is UIProcessSchemaObjects.SignatureCaptureEntry)
            {
                UIProcessSchemaObjects.SignatureCaptureEntry _theEntry = (UIProcessSchemaObjects.SignatureCaptureEntry)_theResource;
                switch (theFieldName)
                {
                    default:
                    case "Name":
                        strResult = _theEntry.Name;
                        break;
                    case "Title":
                        strResult = _theEntry.Title;
                        break;
                    case "Prompt":
                        strResult = _theEntry.Prompt;
                        break;
                    case "Completed":
                        strResult = _theEntry.Completed.ToString();
                        break;
                    case "Required":
                        strResult = _theEntry.Required.ToString();
                        break;
                    case "SignatureBytes":
                        strResult = _theEntry.SignatureBytes;
                        break;
                }
            }
            else if (_theResource is UIProcessSchemaObjects.SingleSelectOtherEntry)
            {
                UIProcessSchemaObjects.SingleSelectOtherEntry _theEntry = (UIProcessSchemaObjects.SingleSelectOtherEntry)_theResource;
                switch (theFieldName)
                {
                    default:
                    case "Name":
                        strResult = _theEntry.Name;
                        break;
                    case "Title":
                        strResult = _theEntry.Title;
                        break;
                    case "Prompt":
                        strResult = _theEntry.Prompt;
                        break;
                    case "Completed":
                        strResult = _theEntry.Completed.ToString();
                        break;
                    case "Required":
                        strResult = _theEntry.Required.ToString();
                        break;
                    case "Options":
                        foreach (string strTemp in _theEntry.Options)
                        {
                            strResult += strTemp;
                            strResult += ":";
                        }
                        break;
                    case "Selections":
                        foreach (string strTemp in _theEntry.Selections)
                        {
                            strResult += strTemp;
                            strResult += ":";
                        }
                        break;
                    case "OtherSelected":
                        strResult = _theEntry.OtherSelected.ToString();
                        break;
                    case "OtherValue":
                        strResult = _theEntry.OtherValue;
                        break;
                }
            }
            else if (_theResource is UIProcessSchemaObjects.SingleSelectEntry)
            {
                UIProcessSchemaObjects.SingleSelectEntry _theEntry = (UIProcessSchemaObjects.SingleSelectEntry)_theResource;
                switch (theFieldName)
                {
                    default:
                    case "Name":
                        strResult = _theEntry.Name;
                        break;
                    case "Title":
                        strResult = _theEntry.Title;
                        break;
                    case "Prompt":
                        strResult = _theEntry.Prompt;
                        break;
                    case "Completed":
                        strResult = _theEntry.Completed.ToString();
                        break;
                    case "Required":
                        strResult = _theEntry.Required.ToString();
                        break;
                    case "Options":
                        foreach (string strTemp in _theEntry.Options)
                        {
                            strResult += strTemp;
                            strResult += ":";
                        }
                        break;
                    case "Selections":
                        foreach (string strTemp in _theEntry.Selections)
                        {
                            strResult += strTemp;
                            strResult += ":";
                        }
                        break;
                }
            }
            else if (_theResource is UIProcessSchemaObjects.TextEntry)
            {
                UIProcessSchemaObjects.TextEntry _theEntry = (UIProcessSchemaObjects.TextEntry)_theResource;
                switch (theFieldName)
                {
                    default:
                    case "Name":
                        strResult = _theEntry.Name;
                        break;
                    case "Title":
                        strResult = _theEntry.Title;
                        break;
                    case "Prompt":
                        strResult = _theEntry.Prompt;
                        break;
                    case "Completed":
                        strResult = _theEntry.Completed.ToString();
                        break;
                    case "Required":
                        strResult = _theEntry.Required.ToString();
                        break;
                    case "TextValue":
                        strResult = _theEntry.TextValue;
                        break;
                }
            }
            else if (_theResource is UIProcessSchemaObjects.UserLoginEntry)
            {
                UIProcessSchemaObjects.UserLoginEntry _theEntry = (UIProcessSchemaObjects.UserLoginEntry)_theResource;
                switch (theFieldName)
                {
                    default:
                    case "Name":
                        strResult = _theEntry.Name;
                        break;
                    case "Title":
                        strResult = _theEntry.Title;
                        break;
                    case "Prompt":
                        strResult = _theEntry.Prompt;
                        break;
                    case "Completed":
                        strResult = _theEntry.Completed.ToString();
                        break;
                    case "Required":
                        strResult = _theEntry.Required.ToString();
                        break;
                    case "UserName":
                        strResult = _theEntry.UserName;
                        break;
                    case "Password":
                        strResult = _theEntry.Password;
                        break;
                }
            }
            else if (_theResource is UIProcessSchemaObjects.YesNoEntry)
            {
                UIProcessSchemaObjects.YesNoEntry _theEntry = (UIProcessSchemaObjects.YesNoEntry)_theResource;
                switch (theFieldName)
                {
                    default:
                    case "Name":
                        strResult = _theEntry.Name;
                        break;
                    case "Title":
                        strResult = _theEntry.Title;
                        break;
                    case "Prompt":
                        strResult = _theEntry.Prompt;
                        break;
                    case "Completed":
                        strResult = _theEntry.Completed.ToString();
                        break;
                    case "Required":
                        strResult = _theEntry.Required.ToString();
                        break;
                    case "Response":
                        strResult = _theEntry.Response;
                        break;
                }
            }
            else if (_theResource is UIProcessSchemaObjects.TextPrompt)
            {
                UIProcessSchemaObjects.TextPrompt _theEntry = (UIProcessSchemaObjects.TextPrompt)_theResource;
                switch (theFieldName)
                {
                    default:
                    case "Name":
                        strResult = _theEntry.Name;
                        break;
                    case "Title":
                        strResult = _theEntry.Title;
                        break;
                    case "Prompt":
                        strResult = _theEntry.Prompt;
                        break;
                    case "Completed":
                        strResult = _theEntry.Completed.ToString();
                        break;
                    case "Required":
                        strResult = _theEntry.Required.ToString();
                        break;
                }
            }
            else
            {
                UIProcessSchemaObjects.FormResource _theEntry = _theResource;
                switch (theFieldName)
                {
                    default:
                    case "Name":
                        strResult = _theEntry.Name;
                        break;
                    case "Title":
                        strResult = _theEntry.Title;
                        break;
                    case "Prompt":
                        strResult = _theEntry.Prompt;
                        break;
                    case "Completed":
                        strResult = _theEntry.Completed.ToString();
                        break;
                    case "Required":
                        strResult = _theEntry.Required.ToString();
                        break;
                }
            }

            return strResult;
        }

        public static void SetFormResourceValue(UIProcessSchemaObjects.Form theForm, string theFormResource, string theFieldName, string theValue)
        {
            UIProcessSchemaObjects.FormResource _theResource = null;

            foreach (UIProcessSchemaObjects.FormResource objTemp in theForm.FormResources)
            {
                if (objTemp.Name == theFormResource)
                {
                    _theResource = objTemp;
                    break;
                }
            }

            if (_theResource is UIProcessSchemaObjects.AddressEntryNA)
            {
                UIProcessSchemaObjects.AddressEntryNA _theEntry = (UIProcessSchemaObjects.AddressEntryNA)_theResource;
                switch (theFieldName)
                {
                    default:
                    case "Name":
                        _theEntry.Name = theValue;
                        break;
                    case "Title":
                        _theEntry.Title = theValue;
                        break;
                    case "Prompt":
                        _theEntry.Prompt = theValue;
                        break;
                    case "Completed":
                        _theEntry.Completed = Convert.ToBoolean(theValue);
                        break;
                    case "Required":
                        _theEntry.Required = Convert.ToBoolean(theValue);
                        break;
                    case "Address1":
                        _theEntry.Address1 = theValue;
                        break;
                    case "Address2":
                        _theEntry.Address2 = theValue;
                        break;
                    case "City":
                        _theEntry.City = theValue;
                        break;
                    case "State":
                        _theEntry.State = theValue;
                        break;
                    case "PostalCode":
                        _theEntry.PostalCode = theValue;
                        break;
                    case "CountryCode":
                        _theEntry.CountryCode = theValue;
                        break;
                    case "NotApplicable":
                        _theEntry.NotApplicable = Convert.ToBoolean(theValue);
                        break;
                }
            }
            else if (_theResource is UIProcessSchemaObjects.AddressEntry)
            {
                UIProcessSchemaObjects.AddressEntry _theEntry = (UIProcessSchemaObjects.AddressEntry)_theResource;
                switch (theFieldName)
                {
                    default:
                    case "Name":
                        _theEntry.Name = theValue;
                        break;
                    case "Title":
                        _theEntry.Title = theValue;
                        break;
                    case "Prompt":
                        _theEntry.Prompt = theValue;
                        break;
                    case "Completed":
                        _theEntry.Completed = Convert.ToBoolean(theValue);
                        break;
                    case "Required":
                        _theEntry.Required = Convert.ToBoolean(theValue);
                        break;
                    case "Address1":
                        _theEntry.Address1 = theValue;
                        break;
                    case "Address2":
                        _theEntry.Address2 = theValue;
                        break;
                    case "City":
                        _theEntry.City = theValue;
                        break;
                    case "State":
                        _theEntry.State = theValue;
                        break;
                    case "PostalCode":
                        _theEntry.PostalCode = theValue;
                        break;
                    case "CountryCode":
                        _theEntry.CountryCode = theValue;
                        break;
                }
            }
            else if (_theResource is UIProcessSchemaObjects.Conditional)
            {
                UIProcessSchemaObjects.Conditional _theEntry = (UIProcessSchemaObjects.Conditional)_theResource;
                switch (theFieldName)
                {
                    default:
                    case "Name":
                        _theEntry.Name = theValue;
                        break;
                    case "Title":
                        _theEntry.Title = theValue;
                        break;
                    case "Prompt":
                        _theEntry.Prompt = theValue;
                        break;
                    case "Completed":
                        _theEntry.Completed = Convert.ToBoolean(theValue);
                        break;
                    case "Required":
                        _theEntry.Required = Convert.ToBoolean(theValue);
                        break;
                    case "Expression":
                        _theEntry.Expression = theValue;
                        break;
                    case "JumpToFormResource":
                        _theEntry.JumpToFormResource = theValue;
                        break;
                }
            }
            else if (_theResource is UIProcessSchemaObjects.DataField)
            {
                UIProcessSchemaObjects.DataField _theEntry = (UIProcessSchemaObjects.DataField)_theResource;
                switch (theFieldName)
                {
                    default:
                    case "Name":
                        _theEntry.Name = theValue;
                        break;
                    case "Title":
                        _theEntry.Title = theValue;
                        break;
                    case "Prompt":
                        _theEntry.Prompt = theValue;
                        break;
                    case "Completed":
                        _theEntry.Completed = Convert.ToBoolean(theValue);
                        break;
                    case "Required":
                        _theEntry.Required = Convert.ToBoolean(theValue);
                        break;
                    case "FieldValue":
                        _theEntry.FieldValue = theValue;
                        break;
                }
            }
            else if (_theResource is UIProcessSchemaObjects.DateTimeEntryNA)
            {
                UIProcessSchemaObjects.DateTimeEntryNA _theEntry = (UIProcessSchemaObjects.DateTimeEntryNA)_theResource;
                switch (theFieldName)
                {
                    default:
                    case "Name":
                        _theEntry.Name = theValue;
                        break;
                    case "Title":
                        _theEntry.Title = theValue;
                        break;
                    case "Prompt":
                        _theEntry.Prompt = theValue;
                        break;
                    case "Completed":
                        _theEntry.Completed = Convert.ToBoolean(theValue);
                        break;
                    case "Required":
                        _theEntry.Required = Convert.ToBoolean(theValue);
                        break;
                    case "Date":
                        _theEntry.Date = theValue;
                        break;
                    case "Time":
                        _theEntry.Time = theValue;
                        break;
                    case "NotApplicable":
                        _theEntry.NotApplicable = Convert.ToBoolean(theValue);
                        break;
                }
            }
            else if (_theResource is UIProcessSchemaObjects.DateTimeEntry)
            {
                UIProcessSchemaObjects.DateTimeEntry _theEntry = (UIProcessSchemaObjects.DateTimeEntry)_theResource;
                switch (theFieldName)
                {
                    default:
                    case "Name":
                        _theEntry.Name = theValue;
                        break;
                    case "Title":
                        _theEntry.Title = theValue;
                        break;
                    case "Prompt":
                        _theEntry.Prompt = theValue;
                        break;
                    case "Completed":
                        _theEntry.Completed = Convert.ToBoolean(theValue);
                        break;
                    case "Required":
                        _theEntry.Required = Convert.ToBoolean(theValue);
                        break;
                    case "Date":
                        _theEntry.Date = theValue;
                        break;
                    case "Time":
                        _theEntry.Time = theValue;
                        break;
                }
            }
            else if (_theResource is UIProcessSchemaObjects.DateEntryNA)
            {
                UIProcessSchemaObjects.DateEntryNA _theEntry = (UIProcessSchemaObjects.DateEntryNA)_theResource;
                switch (theFieldName)
                {
                    default:
                    case "Name":
                        _theEntry.Name = theValue;
                        break;
                    case "Title":
                        _theEntry.Title = theValue;
                        break;
                    case "Prompt":
                        _theEntry.Prompt = theValue;
                        break;
                    case "Completed":
                        _theEntry.Completed = Convert.ToBoolean(theValue);
                        break;
                    case "Required":
                        _theEntry.Required = Convert.ToBoolean(theValue);
                        break;
                    case "Date":
                        _theEntry.Date = theValue;
                        break;
                    case "NotApplicable":
                        _theEntry.NotApplicable = Convert.ToBoolean(theValue);
                        break;
                }
            }
            else if (_theResource is UIProcessSchemaObjects.DateEntry)
            {
                UIProcessSchemaObjects.DateEntry _theEntry = (UIProcessSchemaObjects.DateEntry)_theResource;
                switch (theFieldName)
                {
                    default:
                    case "Name":
                        _theEntry.Name = theValue;
                        break;
                    case "Title":
                        _theEntry.Title = theValue;
                        break;
                    case "Prompt":
                        _theEntry.Prompt = theValue;
                        break;
                    case "Completed":
                        _theEntry.Completed = Convert.ToBoolean(theValue);
                        break;
                    case "Required":
                        _theEntry.Required = Convert.ToBoolean(theValue);
                        break;
                    case "Date":
                        _theEntry.Date = theValue;
                        break;
                }
            }
            else if (_theResource is UIProcessSchemaObjects.GraphicAnnotation)
            {
                UIProcessSchemaObjects.GraphicAnnotation _theEntry = (UIProcessSchemaObjects.GraphicAnnotation)_theResource;
                switch (theFieldName)
                {
                    default:
                    case "Name":
                        _theEntry.Name = theValue;
                        break;
                    case "Title":
                        _theEntry.Title = theValue;
                        break;
                    case "Prompt":
                        _theEntry.Prompt = theValue;
                        break;
                    case "Completed":
                        _theEntry.Completed = Convert.ToBoolean(theValue);
                        break;
                    case "Required":
                        _theEntry.Required = Convert.ToBoolean(theValue);
                        break;
                    case "FullScreen":
                        _theEntry.FullScreen = Convert.ToBoolean(theValue);
                        break;
                    case "ImageBytes":
                        _theEntry.ImageBytes = theValue;
                        break;
                    case "AnnotationBytes":
                        _theEntry.AnnotationBytes = theValue;
                        break;
                }
            }
            else if (_theResource is UIProcessSchemaObjects.GraphicDisplay)
            {
                UIProcessSchemaObjects.GraphicDisplay _theEntry = (UIProcessSchemaObjects.GraphicDisplay)_theResource;
                switch (theFieldName)
                {
                    default:
                    case "Name":
                        _theEntry.Name = theValue;
                        break;
                    case "Title":
                        _theEntry.Title = theValue;
                        break;
                    case "Prompt":
                        _theEntry.Prompt = theValue;
                        break;
                    case "Completed":
                        _theEntry.Completed = Convert.ToBoolean(theValue);
                        break;
                    case "Required":
                        _theEntry.Required = Convert.ToBoolean(theValue);
                        break;
                    case "FullScreen":
                        _theEntry.FullScreen = Convert.ToBoolean(theValue);
                        break;
                    case "ImageBytes":
                        _theEntry.ImageBytes = theValue;
                        break;
                }
            }
            else if (_theResource is UIProcessSchemaObjects.MultiSelectOtherEntry)
            {
                UIProcessSchemaObjects.MultiSelectOtherEntry _theEntry = (UIProcessSchemaObjects.MultiSelectOtherEntry)_theResource;
                switch (theFieldName)
                {
                    default:
                    case "Name":
                        _theEntry.Name = theValue;
                        break;
                    case "Title":
                        _theEntry.Title = theValue;
                        break;
                    case "Prompt":
                        _theEntry.Prompt = theValue;
                        break;
                    case "Completed":
                        _theEntry.Completed = Convert.ToBoolean(theValue);
                        break;
                    case "Required":
                        _theEntry.Required = Convert.ToBoolean(theValue);
                        break;
                    case "Options":
                        string[] strOptions = theValue.Split(':');
                        _theEntry.Options = strOptions;
                        break;
                    case "Selections":
                        string[] strSelections = theValue.Split(':');
                        _theEntry.Selections = strSelections;
                        break;
                    case "OtherSelected":
                        _theEntry.OtherSelected = Convert.ToBoolean(theValue);
                        break;
                    case "OtherValue":
                        _theEntry.OtherValue = theValue;
                        break;
                }
            }
            else if (_theResource is UIProcessSchemaObjects.MultiSelectEntry)
            {
                UIProcessSchemaObjects.MultiSelectEntry _theEntry = (UIProcessSchemaObjects.MultiSelectEntry)_theResource;
                switch (theFieldName)
                {
                    default:
                    case "Name":
                        _theEntry.Name = theValue;
                        break;
                    case "Title":
                        _theEntry.Title = theValue;
                        break;
                    case "Prompt":
                        _theEntry.Prompt = theValue;
                        break;
                    case "Completed":
                        _theEntry.Completed = Convert.ToBoolean(theValue);
                        break;
                    case "Required":
                        _theEntry.Required = Convert.ToBoolean(theValue);
                        break;
                    case "Options":
                        string[] strOptions = theValue.Split(':');
                        _theEntry.Options = strOptions;
                        break;
                    case "Selections":
                        string[] strSelections = theValue.Split(':');
                        _theEntry.Selections = strSelections;
                        break;
                }
            }
            else if (_theResource is UIProcessSchemaObjects.NameEntry)
            {
                UIProcessSchemaObjects.NameEntry _theEntry = (UIProcessSchemaObjects.NameEntry)_theResource;
                switch (theFieldName)
                {
                    default:
                    case "Name":
                        _theEntry.Name = theValue;
                        break;
                    case "Title":
                        _theEntry.Title = theValue;
                        break;
                    case "Prompt":
                        _theEntry.Prompt = theValue;
                        break;
                    case "Completed":
                        _theEntry.Completed = Convert.ToBoolean(theValue);
                        break;
                    case "Required":
                        _theEntry.Required = Convert.ToBoolean(theValue);
                        break;
                    case "NameTitle":
                        _theEntry.NameTitle = theValue;
                        break;
                    case "Given":
                        _theEntry.Given = theValue;
                        break;
                    case "Middle":
                        _theEntry.Middle = theValue;
                        break;
                    case "Family":
                        _theEntry.Family = theValue;
                        break;
                    case "Suffix":
                        _theEntry.Suffix = theValue;
                        break;
                }
            }
            else if (_theResource is UIProcessSchemaObjects.NoteEntry)
            {
                UIProcessSchemaObjects.NoteEntry _theEntry = (UIProcessSchemaObjects.NoteEntry)_theResource;
                switch (theFieldName)
                {
                    default:
                    case "Name":
                        _theEntry.Name = theValue;
                        break;
                    case "Title":
                        _theEntry.Title = theValue;
                        break;
                    case "Prompt":
                        _theEntry.Prompt = theValue;
                        break;
                    case "Completed":
                        _theEntry.Completed = Convert.ToBoolean(theValue);
                        break;
                    case "Required":
                        _theEntry.Required = Convert.ToBoolean(theValue);
                        break;
                    case "NoteText":
                        _theEntry.NoteText = theValue;
                        break;
                }
            }
            else if (_theResource is UIProcessSchemaObjects.NumberEntryNA)
            {
                UIProcessSchemaObjects.NumberEntryNA _theEntry = (UIProcessSchemaObjects.NumberEntryNA)_theResource;
                switch (theFieldName)
                {
                    default:
                    case "Name":
                        _theEntry.Name = theValue;
                        break;
                    case "Title":
                        _theEntry.Title = theValue;
                        break;
                    case "Prompt":
                        _theEntry.Prompt = theValue;
                        break;
                    case "Completed":
                        _theEntry.Completed = Convert.ToBoolean(theValue);
                        break;
                    case "Required":
                        _theEntry.Required = Convert.ToBoolean(theValue);
                        break;
                    case "NumberValue":
                        _theEntry.NumberValue = theValue;
                        break;
                    case "NotApplicable":
                        _theEntry.NotApplicable = Convert.ToBoolean(theValue);
                        break;
                }
            }
            else if (_theResource is UIProcessSchemaObjects.NumberEntry)
            {
                UIProcessSchemaObjects.NumberEntry _theEntry = (UIProcessSchemaObjects.NumberEntry)_theResource;
                switch (theFieldName)
                {
                    default:
                    case "Name":
                        _theEntry.Name = theValue;
                        break;
                    case "Title":
                        _theEntry.Title = theValue;
                        break;
                    case "Prompt":
                        _theEntry.Prompt = theValue;
                        break;
                    case "Completed":
                        _theEntry.Completed = Convert.ToBoolean(theValue);
                        break;
                    case "Required":
                        _theEntry.Required = Convert.ToBoolean(theValue);
                        break;
                    case "NumberValue":
                        _theEntry.NumberValue = theValue;
                        break;
                }
            }
            else if (_theResource is UIProcessSchemaObjects.PasswordEntry)
            {
                UIProcessSchemaObjects.PasswordEntry _theEntry = (UIProcessSchemaObjects.PasswordEntry)_theResource;
                switch (theFieldName)
                {
                    default:
                    case "Name":
                        _theEntry.Name = theValue;
                        break;
                    case "Title":
                        _theEntry.Title = theValue;
                        break;
                    case "Prompt":
                        _theEntry.Prompt = theValue;
                        break;
                    case "Completed":
                        _theEntry.Completed = Convert.ToBoolean(theValue);
                        break;
                    case "Required":
                        _theEntry.Required = Convert.ToBoolean(theValue);
                        break;
                    case "Password":
                        _theEntry.Password = theValue;
                        break;
                }
            }
            else if (_theResource is UIProcessSchemaObjects.PhoneEntryNA)
            {
                UIProcessSchemaObjects.PhoneEntryNA _theEntry = (UIProcessSchemaObjects.PhoneEntryNA)_theResource;
                switch (theFieldName)
                {
                    default:
                    case "Name":
                        _theEntry.Name = theValue;
                        break;
                    case "Title":
                        _theEntry.Title = theValue;
                        break;
                    case "Prompt":
                        _theEntry.Prompt = theValue;
                        break;
                    case "Completed":
                        _theEntry.Completed = Convert.ToBoolean(theValue);
                        break;
                    case "Required":
                        _theEntry.Required = Convert.ToBoolean(theValue);
                        break;
                    case "NationalCode":
                        _theEntry.NationalCode = theValue;
                        break;
                    case "CountryCode":
                        _theEntry.CountryCode = theValue;
                        break;
                    case "AreaCode":
                        _theEntry.AreaCode = theValue;
                        break;
                    case "Number":
                        _theEntry.Number = theValue;
                        break;
                    case "Extension":
                        _theEntry.Extension = theValue;
                        break;
                    case "Pin":
                        _theEntry.Pin = theValue;
                        break;
                    case "NotApplicable":
                        _theEntry.NotApplicable = Convert.ToBoolean(theValue);
                        break;
                }
            }
            else if (_theResource is UIProcessSchemaObjects.PhoneEntry)
            {
                UIProcessSchemaObjects.PhoneEntry _theEntry = (UIProcessSchemaObjects.PhoneEntry)_theResource;
                switch (theFieldName)
                {
                    default:
                    case "Name":
                        _theEntry.Name = theValue;
                        break;
                    case "Title":
                        _theEntry.Title = theValue;
                        break;
                    case "Prompt":
                        _theEntry.Prompt = theValue;
                        break;
                    case "Completed":
                        _theEntry.Completed = Convert.ToBoolean(theValue);
                        break;
                    case "Required":
                        _theEntry.Required = Convert.ToBoolean(theValue);
                        break;
                    case "NationalCode":
                        _theEntry.NationalCode = theValue;
                        break;
                    case "CountryCode":
                        _theEntry.CountryCode = theValue;
                        break;
                    case "AreaCode":
                        _theEntry.AreaCode = theValue;
                        break;
                    case "Number":
                        _theEntry.Number = theValue;
                        break;
                    case "Extension":
                        _theEntry.Extension = theValue;
                        break;
                    case "Pin":
                        _theEntry.Pin = theValue;
                        break;
                }
            }
            else if (_theResource is UIProcessSchemaObjects.PostalCodeEntryNA)
            {
                UIProcessSchemaObjects.PostalCodeEntryNA _theEntry = (UIProcessSchemaObjects.PostalCodeEntryNA)_theResource;
                switch (theFieldName)
                {
                    default:
                    case "Name":
                        _theEntry.Name = theValue;
                        break;
                    case "Title":
                        _theEntry.Title = theValue;
                        break;
                    case "Prompt":
                        _theEntry.Prompt = theValue;
                        break;
                    case "Completed":
                        _theEntry.Completed = Convert.ToBoolean(theValue);
                        break;
                    case "Required":
                        _theEntry.Required = Convert.ToBoolean(theValue);
                        break;
                    case "PostalCode":
                        _theEntry.PostalCode = theValue;
                        break;
                    case "NotApplicable":
                        _theEntry.NotApplicable = Convert.ToBoolean(theValue);
                        break;
                }
            }
            else if (_theResource is UIProcessSchemaObjects.PostalCodeEntry)
            {
                UIProcessSchemaObjects.PostalCodeEntry _theEntry = (UIProcessSchemaObjects.PostalCodeEntry)_theResource;
                switch (theFieldName)
                {
                    default:
                    case "Name":
                        _theEntry.Name = theValue;
                        break;
                    case "Title":
                        _theEntry.Title = theValue;
                        break;
                    case "Prompt":
                        _theEntry.Prompt = theValue;
                        break;
                    case "Completed":
                        _theEntry.Completed = Convert.ToBoolean(theValue);
                        break;
                    case "Required":
                        _theEntry.Required = Convert.ToBoolean(theValue);
                        break;
                    case "PostalCode":
                        _theEntry.PostalCode = theValue;
                        break;
                }
            }
            else if (_theResource is UIProcessSchemaObjects.SignatureCaptureEntry)
            {
                UIProcessSchemaObjects.SignatureCaptureEntry _theEntry = (UIProcessSchemaObjects.SignatureCaptureEntry)_theResource;
                switch (theFieldName)
                {
                    default:
                    case "Name":
                        _theEntry.Name = theValue;
                        break;
                    case "Title":
                        _theEntry.Title = theValue;
                        break;
                    case "Prompt":
                        _theEntry.Prompt = theValue;
                        break;
                    case "Completed":
                        _theEntry.Completed = Convert.ToBoolean(theValue);
                        break;
                    case "Required":
                        _theEntry.Required = Convert.ToBoolean(theValue);
                        break;
                    case "SignatureBytes":
                        _theEntry.SignatureBytes = theValue;
                        break;
                }
            }
            else if (_theResource is UIProcessSchemaObjects.SingleSelectOtherEntry)
            {
                UIProcessSchemaObjects.SingleSelectOtherEntry _theEntry = (UIProcessSchemaObjects.SingleSelectOtherEntry)_theResource;
                switch (theFieldName)
                {
                    default:
                    case "Name":
                        _theEntry.Name = theValue;
                        break;
                    case "Title":
                        _theEntry.Title = theValue;
                        break;
                    case "Prompt":
                        _theEntry.Prompt = theValue;
                        break;
                    case "Completed":
                        _theEntry.Completed = Convert.ToBoolean(theValue);
                        break;
                    case "Required":
                        _theEntry.Required = Convert.ToBoolean(theValue);
                        break;
                    case "Options":
                        string[] strOptions = theValue.Split(':');
                        _theEntry.Options = strOptions;
                        break;
                    case "Selections":
                        string[] strSelections = theValue.Split(':');
                        _theEntry.Selections = strSelections;
                        break;
                    case "OtherSelected":
                        _theEntry.OtherSelected = Convert.ToBoolean(theValue);
                        break;
                    case "OtherValue":
                        _theEntry.OtherValue = theValue;
                        break;
                }
            }
            else if (_theResource is UIProcessSchemaObjects.SingleSelectEntry)
            {
                UIProcessSchemaObjects.SingleSelectEntry _theEntry = (UIProcessSchemaObjects.SingleSelectEntry)_theResource;
                switch (theFieldName)
                {
                    default:
                    case "Name":
                        _theEntry.Name = theValue;
                        break;
                    case "Title":
                        _theEntry.Title = theValue;
                        break;
                    case "Prompt":
                        _theEntry.Prompt = theValue;
                        break;
                    case "Completed":
                        _theEntry.Completed = Convert.ToBoolean(theValue);
                        break;
                    case "Required":
                        _theEntry.Required = Convert.ToBoolean(theValue);
                        break;
                    case "Options":
                        string[] strOptions = theValue.Split(':');
                        _theEntry.Options = strOptions;
                        break;
                    case "Selections":
                        string[] strSelections = theValue.Split(':');
                        _theEntry.Selections = strSelections;
                        break;
                }
            }
            else if (_theResource is UIProcessSchemaObjects.TextEntry)
            {
                UIProcessSchemaObjects.TextEntry _theEntry = (UIProcessSchemaObjects.TextEntry)_theResource;
                switch (theFieldName)
                {
                    default:
                    case "Name":
                        _theEntry.Name = theValue;
                        break;
                    case "Title":
                        _theEntry.Title = theValue;
                        break;
                    case "Prompt":
                        _theEntry.Prompt = theValue;
                        break;
                    case "Completed":
                        _theEntry.Completed = Convert.ToBoolean(theValue);
                        break;
                    case "Required":
                        _theEntry.Required = Convert.ToBoolean(theValue);
                        break;
                    case "TextValue":
                        _theEntry.TextValue = theValue;
                        break;
                }
            }
            else if (_theResource is UIProcessSchemaObjects.UserLoginEntry)
            {
                UIProcessSchemaObjects.UserLoginEntry _theEntry = (UIProcessSchemaObjects.UserLoginEntry)_theResource;
                switch (theFieldName)
                {
                    default:
                    case "Name":
                        _theEntry.Name = theValue;
                        break;
                    case "Title":
                        _theEntry.Title = theValue;
                        break;
                    case "Prompt":
                        _theEntry.Prompt = theValue;
                        break;
                    case "Completed":
                        _theEntry.Completed = Convert.ToBoolean(theValue);
                        break;
                    case "Required":
                        _theEntry.Required = Convert.ToBoolean(theValue);
                        break;
                    case "UserName":
                        _theEntry.UserName = theValue;
                        break;
                    case "Password":
                        _theEntry.Password = theValue;
                        break;
                }
            }
            else if (_theResource is UIProcessSchemaObjects.YesNoEntry)
            {
                UIProcessSchemaObjects.YesNoEntry _theEntry = (UIProcessSchemaObjects.YesNoEntry)_theResource;
                switch (theFieldName)
                {
                    default:
                    case "Name":
                        _theEntry.Name = theValue;
                        break;
                    case "Title":
                        _theEntry.Title = theValue;
                        break;
                    case "Prompt":
                        _theEntry.Prompt = theValue;
                        break;
                    case "Completed":
                        _theEntry.Completed = Convert.ToBoolean(theValue);
                        break;
                    case "Required":
                        _theEntry.Required = Convert.ToBoolean(theValue);
                        break;
                    case "Response":
                        _theEntry.Response = theValue;
                        break;
                }
            }
            else if (_theResource is UIProcessSchemaObjects.TextPrompt)
            {
                UIProcessSchemaObjects.TextPrompt _theEntry = (UIProcessSchemaObjects.TextPrompt)_theResource;
                switch (theFieldName)
                {
                    default:
                    case "Name":
                        _theEntry.Name = theValue;
                        break;
                    case "Title":
                        _theEntry.Title = theValue;
                        break;
                    case "Prompt":
                        _theEntry.Prompt = theValue;
                        break;
                    case "Completed":
                        _theEntry.Completed = Convert.ToBoolean(theValue);
                        break;
                    case "Required":
                        _theEntry.Required = Convert.ToBoolean(theValue);
                        break;
                }
            }
            else
            {
                UIProcessSchemaObjects.FormResource _theEntry = _theResource;
                switch (theFieldName)
                {
                    default:
                    case "Name":
                        _theEntry.Name = theValue;
                        break;
                    case "Title":
                        _theEntry.Title = theValue;
                        break;
                    case "Prompt":
                        _theEntry.Prompt = theValue;
                        break;
                    case "Completed":
                        _theEntry.Completed = Convert.ToBoolean(theValue);
                        break;
                    case "Required":
                        _theEntry.Required = Convert.ToBoolean(theValue);
                        break;
                }
            }
        }
    }
}
